home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / c / sozobon / sozuti09.zoo / sozdistr / doc / binary.doc / make.doc < prev    next >
Encoding:
Text File  |  1991-06-23  |  28.1 KB  |  652 lines

  1.                              Using MAKE
  2.  
  3.                      Documentation by Ian Lepore
  4.                   This document is NOT copyrighted.
  5.  
  6. Make is a standard Unix utility which is widely available as a Public 
  7. Domain utility for a variety of operating systems.  This document 
  8. describes the usage of the make utility.  It is not specific to a 
  9. given implementation of make; features available in your version may 
  10. not be docuemented here.
  11.  
  12. AUTHOR'S NOTE
  13.  
  14.   The information in this document was culled from Unix manuals and 
  15.   my own experience (admittedly limited) in working with the source 
  16.   code to a PD make.  I apologize in advance for any inaccuracies.
  17.  
  18. OVERVIEW
  19.  
  20.   Make is a utility designed to assist in keeping files up to date 
  21.   when a process exists to convert files from one state to another.  
  22.   While it is typically used in the context of developing programs, 
  23.   make can be used for other similar tasks, such as maintaining a 
  24.   library of archive files.  The primary focus of this document will 
  25.   be in the use of make as a C programming tool.
  26.  
  27.   For all but the smallest of programming projects, it is convenient 
  28.   to break the source code into a number of separate modules.  While 
  29.   this can improve compile times, it increases the burden on the 
  30.   programmer, who now has to remember to recompile recompile all the 
  31.   modules that were changed during the edit cycle.  Make relieves the 
  32.   programmer of this burden by automatically re-compiling only the 
  33.   modules which were changed.
  34.  
  35.   Make is driven by command line parameters, and specifications in a 
  36.   file (called a 'makefile') which describe the relationships between 
  37.   the end program and the source code modules required to generate 
  38.   it.  When make is run, it reads the makefile, compares the file 
  39.   timestamps on the various modules, and invokes the appropriate 
  40.   processes to bring everything up to date.
  41.  
  42. CONVENTIONS
  43.  
  44.   In syntax diagrams, the following conventions are used:
  45.  
  46.   [x]  Items appearing in brackets are optional.
  47.  
  48.   x|y  Items separated by a vertical bar indicate a choice between 
  49.        mutually exclusive items.
  50.  
  51.   ...  The elipsis indicates a list of items may be provided.
  52.  
  53.   When discussing the actions of make in relation to file types, the 
  54.   following assumptions are made for this document:
  55.  
  56.   .PRG files are executable programs.  They are created by a linker 
  57.        program, which combines object files and modules extracted 
  58.        from libraries into a single executable program file.
  59.  
  60.   .O   files are object files.  They are the output of a language 
  61.        processor such as a C compiler, or an assembler.
  62.  
  63.   .C   files contain C source code.
  64.  
  65.   .S   files contain assembler language source code.
  66.  
  67.   .H   files contain C source code, and are included from within 
  68.        other C files, rather than compiled directly.
  69.  
  70.   For the purposes of this document, the following 'natural' 
  71.   progression from source code to end program is assumed:
  72.  
  73.      [.C|.S] -> .O -> .PRG
  74.  
  75.   The 'natural progression' is discussed in detail under SUFFIXES.
  76.  
  77. TERMINOLOGY
  78.  
  79.   Target
  80.  
  81.      A target is the output of a process.  It will have one or more 
  82.      dependents, and a set of rules or commands describing how the 
  83.      dependents are transformed into the target.  Syntactically, a 
  84.      target appears to the left of a colon in the makefile.
  85.  
  86.   Primary Target
  87.  
  88.      The first target encountered in a makefile is the primary 
  89.      target.  In the programming context, this would be the 
  90.      executable program file.
  91.  
  92.   Dependent
  93.  
  94.      A dependent is a file which is required to create a given 
  95.      target.  Syntactically, a dependent appears to the right of a 
  96.      colon in the makefile.  In a programming context, the object 
  97.      modules would be the dependents for the executable program, and 
  98.      the source code modules would be the dependents for the object 
  99.      modules.
  100.  
  101.   Dynamic Dependency
  102.  
  103.      A dynamic dependency is one that is created by make internally 
  104.      (as opposed to being specified explicitly within the makefile).  
  105.      Dynamic dependencies are created through the SUFFIXES mechanism 
  106.      and the builtin rules.
  107.  
  108.   Macro
  109.  
  110.      A macro is a string of characters which are substituted for 
  111.      another string as make processes lines from the makefile.  
  112.      Several builtin macros are provided by make; additional macros 
  113.      may be specified in the makefile or on the command line.
  114.  
  115.   Command
  116.  
  117.      A command is a single line containing a command which is passed 
  118.      to the shell (or whatever command execution mechanism exists 
  119.      within the operating system).  Commands are associated with 
  120.      rules and targets.  The commands within a rule describe a 
  121.      generic process ("this is how to turn C source code files into 
  122.      object files"), while the commands associated with a target are 
  123.      more specific ("this is how to link together all object modules 
  124.      and libraries which make up my program").
  125.  
  126.   Rule
  127.  
  128.      Rules are sets of commands which specify the processes used to 
  129.      keep targets up to date.  Make has a set of builtin rules, and 
  130.      additional rules can be defined in the makefile.  The builtin 
  131.      rules differ for each implementation of make, and are generally 
  132.      appropriate to the environment and compilers which the make 
  133.      implementation was designed to support.  Some versions of make 
  134.      have the builtin rules written into the source code (making them 
  135.      difficult to change), and other implementations read the default 
  136.      rules from a file such as MAKE.INI, allowing the programmer to 
  137.      customize make.
  138.  
  139. BASIC OPERATION
  140.  
  141.   The basic function of make is to update target files by ensuring 
  142.   that all of the dependent files are up to date.  This is done by 
  143.   comparing the file timestamps of the target and all its dependents.  
  144.   When any dependents have a more recent modified date & time than 
  145.   the target, the corresponding set of rules is invoked to bring the 
  146.   target up to date.
  147.  
  148.   The relationships between targets and dependents are specified in 
  149.   the makefile, or can be 'intuited' by make based upon the known 
  150.   SUFFIXES and builtin rules.  There can be multiple levels of 
  151.   dependency between the primary target and the lowest-level 
  152.   dependents.  For example, the file 'myprog.prg' may depend upon 
  153.   'mymain.o' and 'mysubr.o'.  Make will internally determine that 
  154.   mymain.o and mysubr.o depend on mymain.c and mysubr.c, 
  155.   respectively.  (When this occurs, .o files become targets of the .c 
  156.   files.  In this example, the .c files are the lowest-level 
  157.   dependents, but this need not be the case.  You may, for example, 
  158.   have a process which generates a .c file, such as the lex utility.)  
  159.   Make will do a depth-first recursive search to determine which 
  160.   files need to be brought up to date.
  161.  
  162.   The basic format of the specifications in a makefile is:
  163.  
  164.      target [target...] : [dependent [dependent...]]   [# comment]
  165.      [<tab> [@][command]                               [# comment]]
  166.      [<tab> [@][command]                               [# comment]]
  167.  
  168.   The sharp character ('#') is used as a comment delimiter.  All 
  169.   characters following the sharp on a line are ignored.
  170.  
  171.   Some implementations of make require the <tab> character to be the 
  172.   first character on a command line, other implementations will 
  173.   accept a space or a <tab>.  Command lines are optional.  When 
  174.   commands are specified, they will be used to process a dependent 
  175.   file into the target file.  When no command lines are present for a 
  176.   given target, builtin rules may be invoked (if they exist for the 
  177.   target/dependent combination).  When no commands are specified, and 
  178.   no builtin rules exist, make will issue an error message similar to 
  179.   "don't know how to make (dependent name)".
  180.  
  181.   A trailing backslash ('\') character at the end of a line can be 
  182.   used to continue statements onto the following line.  The backslash 
  183.   must be the last character on the line; if whitespace characters 
  184.   appear following the backslash, it does not signal a continuation.
  185.  
  186.   By default, make lists each command line before it is executed.  If 
  187.   the command is preceeded with the '@' character, it will not be 
  188.   listed.
  189.  
  190.   Some implementations of make require at least one dependent to be 
  191.   listed on a target line.  Other versions will allow a target 
  192.   without any dependents, providing that the filetype of the target 
  193.   is known via the SUFFIXES mechanism (allowing make to establish a 
  194.   dynamic dependency for the target.)
  195.  
  196.   If your version of make includes the end-program filetype (eg, 
  197.   .PRG) in its SUFFIXES list, a simple makefile would look like:
  198.  
  199.      myprog.prg:
  200.        (or)
  201.      myprog.prg: myprog.o
  202.  
  203.   (The second format might be required if your version of make 
  204.   requires dependents to be listed on a target line.)  If your make 
  205.   does not implicitly understand the .PRG type, you would need a rule 
  206.   specifying how to run the linker after the compile is done:
  207.  
  208.      myprog.prg: 
  209.      <tab>linker.prg -o myprog.prg myprog.o lib1.a lib2.a
  210.  
  211.   For a more complex program, additional dependencies might be 
  212.   specified, as shown in the following example:
  213.  
  214.      myprog.prg: main.o iosubr.o process.o
  215.      <tab>linker.prg -o myprog.prg main.o iosubr.o process.o lib.a
  216.  
  217.      main.o iosubr.o process.o: myhdr.h
  218.  
  219.   This example shows that there are 3 .o files which must be up to 
  220.   date to make myprog.prg.  In addition, each of those three modules 
  221.   depends on myhdr.h, that is, if myhdr.h has a more recent timestamp 
  222.   than any of the .o files, the .o file(s) would have to be brought 
  223.   up to date before myprog.prg is updated.  (Make will dynamically 
  224.   determine that the way to bring the .o files up to date is to 
  225.   compile the .c files.)  
  226.  
  227.   A common error with make is to define myhdr.h as a dependent of the 
  228.   .c files instead of the .o files.  Be careful with this:  it is the 
  229.   .o files which must be current to update myprog.prg, even though it 
  230.   is the .c files which contain the references to myhdr.h.  The 
  231.   reason for this is that make's builtin rules don't describe how to 
  232.   transform a .h file into a .c file, which is what would be 
  233.   attempted if the dependencies were tied to the .c files.  By tying 
  234.   the dependency to the .o files, you force make to recompile the .c 
  235.   files when myhdr.h is modified, which is in fact the correct way to 
  236.   update your program after a modification to a header file.
  237.  
  238. SUFFIXES
  239.  
  240.   Much of the functionality of make is provided by the SUFFIXES 
  241.   mechanism, which consists of the .SUFFIXES 'special target', and a 
  242.   set of generic file-transformation rules.
  243.  
  244.   Generally speaking, .SUFFIXES provides a list of 'known' filetypes.  
  245.   The rules provide the commands needed to turn certain filetypes 
  246.   into other filetypes.  The combination of SUFFIXES and rules allows 
  247.   make to 'know' that .C files can be turned into .O files, for 
  248.   example.  So, when make encounters a filename that ends in .O, it 
  249.   checks to see if there is a corresponding .C file.  If there is, 
  250.   and it is more recent than the .O, then make will know that the .C 
  251.   file has to be recompiled.
  252.  
  253.   All implementations of make have a builtin list of filetypes in the 
  254.   .SUFFIXES special target.  You may specify additional types by 
  255.   coding a .SUFFIXES line in your makefile.  The types you specify in 
  256.   the makefile will be added to the end of the internal list.  (Of 
  257.   course, you generally have to provide rules to go with the suffixes 
  258.   you add; these can also be specified in the makefile.)  To 
  259.   completely replace the internal list with your own list of 
  260.   suffixes, code a .SUFFIXES line with no dependents, then code your 
  261.   own list, as follows:
  262.  
  263.      .SUFFIXES:               # wipe out all known suffixes
  264.      .SUFFIXES: .x .y .z      # supply a replacement list
  265.  
  266.   Unless you get involved in customizing your version of make to add 
  267.   new language processors that it doesn't already know about, the 
  268.   preceeding summary is really all you need to know about SUFFIXES.  
  269.   For those who need in-depth info, the following paragraphs provide 
  270.   a more detailed look at how the SUFFIXES mechanism functions.
  271.  
  272.   A rule is indicated by a special format of a target-with-commands 
  273.   sequence which has no dependents.  The target name for a rule is 
  274.   the concatenation of the filetypes involved in the transformation.  
  275.   The leading '.' in a rule's target name is what make keys on to 
  276.   distinguish a rule from a normal target/command sequence.
  277.  
  278.   To implement the assumptions about the 'natural progression' of 
  279.   source-to-executable that is mentioned in the CONVENTIONS section, 
  280.   the following builtin rules would be implemented in make:
  281.  
  282.      .SUFFIXES: .prg .o .s .c
  283.  
  284.      .c.prg:                  # Turn a .c into a .prg
  285.        cc $< -o $@
  286.  
  287.      .c.o:                    # Turn a .c into a .o
  288.        cc -c $< 
  289.  
  290.      .s.o:                    # Turn a .s into a .o
  291.        asm $<
  292.  
  293.   This example assumes that the 'cc' program knows how to run the 
  294.   linker as well as the compiler, and that it will do so unless the 
  295.   '-c' flag is used.  This is fairly typical of C compilers.
  296.  
  297.   '$<' is a special macro that works only within builtin rules.  '$@' 
  298.   is a builtin macro that works anywhere.  When a builtin rule is 
  299.   invoked by make, the $< will be replaced by the full name 
  300.   (including filetype) of the dependent file which triggered the 
  301.   rule.  (Another builtin macro for rules, '$*', will be replaced 
  302.   with the basename (without suffix) of the dependent that triggered 
  303.   the rule.)  The $@ will be replaced by the full name of the target 
  304.   which is being made.  Therefore, if the .c.prg rule was invoked to 
  305.   update myprog.prg, the command line would expand into:
  306.   
  307.      cc myprog.c -o myprog.prg
  308.  
  309.   For each target and dependent name make encounters when processing 
  310.   the makefile, it invokes the SUFFIXES mechanism to try to establish 
  311.   a dynamic dependency.  When new dependents are added to a target 
  312.   via this mechanism, they are also potential targets, and an attempt 
  313.   is made to establish dynamic dependency for them as well.  This 
  314.   process continues recursively until no further levels of dependency 
  315.   can be established.
  316.  
  317.   When the SUFFIXES mechanism is invoked, it performs as follows:
  318.  
  319.   -  The filename to be checked is separated into a basename and a 
  320.      suffix (by splitting it at the last '.' character).  For 
  321.      example, myprog.o would be split into a basename of 'myprog', 
  322.      and a suffix of '.o'.
  323.  
  324.   -  Loop for each suffix found in the .SUFFIXES list:
  325.  
  326.      - The suffix from the filename is concatenated behind  the 
  327.        suffix from the list.  For example, the first check would be 
  328.        for '.prg.o' (.o from the filename, and .prg from the list).
  329.  
  330.      - Loop for each builtin rule:
  331.  
  332.        -  Check to see if the rule matches the current concatention 
  333.           of suffixes.  For example, the first iteration of the outer 
  334.           loop would fail, because there is no '.prg.o' rule.  The 
  335.           last iteration of the outer loop would build a concatention 
  336.           of '.c.o', and a rule for this transformation does exist.
  337.  
  338.        -  If a rule does exist for the current combination, the 
  339.           filetype from the suffixes list is concatenated to the 
  340.           file's basename.  An attempt is made to get the timestamp 
  341.           for the resulting filename.  If the attempt fails, there is 
  342.           no such file, and processing continues with the next rule.  
  343.           If the file does exist, its timestamp is compared with that 
  344.           of the target.  If the target needs to be updated, a 
  345.           dependency is dynamically added, and the $< and $* macros 
  346.           are set to the fullname and basename of the dependent.  For 
  347.           example, if myprog.c had a more recent timestamp than 
  348.           myprog.o, myprog.c would be added as a dependent of 
  349.           myprog.o.
  350.  
  351.   It should be mentioned that make is sensitive to the order of the 
  352.   filetypes in .SUFFIXES, and the order the rules are listed.  The 
  353.   .SUFFIXES are tried in a left-to-right sequence, and the list of 
  354.   builtin rules is scanned in the order that they are specified (in 
  355.   the MAKE.INI file).  The first valid combination of the current 
  356.   filetype with a type in .SUFFIXES that has a corresponding rule 
  357.   will be used.  This is generally only important when you are 
  358.   building or adding to the builtin rules for your version of make.
  359.  
  360. MACROS
  361.  
  362.   Macros provide a simple string-substitution facility for make.  
  363.   Macros may be defined in the makefile, on the command line, and in 
  364.   the MAKE.INI file (if such exists).  In addition, make provides 
  365.   several builtin macros.
  366.  
  367.   A macro is defined when make sees a name to the left of an '='.  
  368.   All the characters on the line which follow the '=' (up to a sharp 
  369.   character, if one is present) are the string value assigned to the 
  370.   macro.  The following are all valid macro definitions:
  371.  
  372.      RE/OPTIONS = -f -a -z2
  373.      2 = 27
  374.      OBJ = main.o subr1.o subr2.o \
  375.            subr3.o 
  376.  
  377.   By convention, macro names are usually specified in uppercase, but 
  378.   lower and mixed case names are syntactically legal.  As can be seen 
  379.   in the example, make places virtually no restrictions on the name 
  380.   of a macro.  The last example demonstrates a continuation line.  
  381.   Note that the leading whitespace on the continuation line is 
  382.   removed by the continuation line mechanism.
  383.  
  384.   If a macro is defined multiple times, the most recently encountered 
  385.   value is used.  A macro can be redefined to have a null value by 
  386.   coding 'name=' with no value to the right of the '='.
  387.  
  388.   To refer to a macro in the makefile, it is coded as $(name).  For 
  389.   example, the following lines from a makefile:
  390.  
  391.      OBJ = main.o subr1.o subr2.o subr3.o
  392.  
  393.      myprog.prg: $(OBJ)
  394.      <tab>linker.prg -o myprog.prg $(OBJ)
  395.  
  396.      $(OBJ): myprog.h
  397.  
  398.   Would be expanded as:
  399.  
  400.      myprog.prg: main.o subr1.o subr2.o subr3.o
  401.      <tab>linker.prg -o myprog.prg main.o subr1.o subr2.o subr3.o
  402.  
  403.      main.o subr1.o subr2.o subr3.o: myprog.h
  404.  
  405.   If a macro is referred to which has never been defined, a null 
  406.   string is substituted for the macro, and no error or warning is 
  407.   given.
  408.  
  409.   In addition to macros defined by the user, make provides several 
  410.   builtin macros, which may be used in command lines, as follows:
  411.  
  412.      $@   - The full name of the current target.
  413.      $?   - The list of dependents which triggered this target to be 
  414.             remade.
  415.      $<   - The full name of the current dependent.
  416.      $*   - The base name of the current dependent.
  417.  
  418.    
  419.   The $@ and $? macros are available within any command line in the 
  420.   makefile.  The $< and $* macros are only valid within rules of the 
  421.   the form '.name1.name2:', as descibed in the SUFFIXES section.
  422.  
  423.   Given the following example makefile:
  424.  
  425.      LFLAGS = -m -s
  426.      OBJ = main.o subr1.o subr2.o subr3.o
  427.  
  428.      myprog.prg: $(OBJ)
  429.      <tab>linker.prg $(LFLAGS) -o $@ $(OBJ)
  430.      <tab>size.prg $?
  431.  
  432.   If make determined that main.o and subr2.o were out of date, it 
  433.   would find and recompile main.c and subr2.c (thru the SUFFIXES 
  434.   mechanism), then it would execute the following 2 commands:
  435.  
  436.      linker.prg -m -s -o myprog.prg main.o subr1.o subr2.o subr3.o
  437.      size.prg main.o subr2.o
  438.  
  439.   As you can see, this makefile causes the program be rebuilt, and it 
  440.   also calls the 'size' program to report on the new object module 
  441.   sizes, only for the modules which were changed.
  442.  
  443.   Most versions of make define several 'standard' macros in the 
  444.   MAKE.INI file, which work in conjunction with the builtin rules.  
  445.   The most prevelent of these is CFLAGS, used to allow the programmer 
  446.   to override default compiler options.  For example, the MAKE.INI 
  447.   file (or builtin rules) might contain the following:
  448.  
  449.      CFLAGS =
  450.  
  451.      .c.o:
  452.      <tab>cc $(CFLAGS) -c $<
  453.  
  454.   The initial definition 'CFLAGS =' will define the CFLAGS macro as 
  455.   having a null value.  If the programmer codes a makefile such as:
  456.  
  457.      CFLAGS = -O
  458.  
  459.      myprog.prg:
  460.      <tab>linker.prg -o myprog.prg myprog.o
  461.  
  462.   Then when make's builtin rule is invoked to compile myprog.c, the 
  463.   '-O' option will be passed to the compiler.
  464.  
  465. SPECIAL TARGETS
  466.  
  467.   In addition to the .SUFFIXES and .name1.name2 special targets which 
  468.   are described in the SUFFIXES section, most implementations of make 
  469.   define several other 'special' targets.  Generally, these are used 
  470.   to set switches and options from within a makefile which are 
  471.   normally specified on the command line.  The most common of these 
  472.   special targets are:
  473.  
  474.      .IGNORE   Run in 'ignore return codes' mode.   (Command line -i)
  475.      .SILENT   Run in 'silent' mode.                (Command line -s)
  476.      .PRINT    Print out structures before making.  (Command line -p)
  477.      .NORUN    Pretend to make; don't execute cmds. (Command line -n)
  478.      .DEBUG    Print debugging info.                (Command line -d)
  479.  
  480.   When these targets are encountered in a makefile (or MAKE.INI), 
  481.   they cause the appropriate options to take effect, just as if they 
  482.   had been specified on the command line.  Do not specify any 
  483.   dependents or commands with these targets.  For example, to set 
  484.   silent mode and debug mode, specify the following in the makefile:
  485.  
  486.      .SILENT:
  487.      .DEBUG:
  488.  
  489.      myprog.prg: #etc, etc
  490.  
  491. COMMAND LINE PARAMETERS
  492.  
  493.   When make is run, it can accept 3 types of command line parameters:
  494.  
  495.      - Options
  496.      - Macros
  497.      - Targets
  498.  
  499.   The options available will vary with each implementation.  The 
  500.   general format of the make commandline is:
  501.  
  502.      make [options] [macros] [targets]
  503.  
  504.   Note that all parameters are optional; if no parameters are 
  505.   specified, make will search the current directory for a file named 
  506.   'makefile', and will process it to make the primary target.
  507.  
  508.   The options available are:
  509.  
  510.      -d   Debug mode.  Print copious amounts of debugging information 
  511.           as the program runs.  Useful mainly for debugging a new 
  512.           MAKE.INI file.
  513.  
  514.      -f   Alternate input file.  If, for some reason, the 
  515.           specifications for your project are in a file with a name 
  516.           other than 'makefile', this flag can be used to provide the 
  517.           name of the specifications file.  Typically, this must be 
  518.           the last option on the command line (preceeding any macros 
  519.           or targets).  The name of the alternate input file is 
  520.           specified following the -f.
  521.  
  522.      -i   Ignore return codes mode.  Most programs (commands) will 
  523.           exit with a return code (or status code) of 0 to indicate 
  524.           success.  By default, make will stop processing if any 
  525.           command returns a non-zero value.  This flag overrides this 
  526.           option, and allows make to continue processing regardless 
  527.           of the return codes from commands.
  528.  
  529.      -n   Norun mode.  Make will list all the commands that would be 
  530.           executed based on the current file timestamps, but it 
  531.           doesn't actually execute anything.
  532.  
  533.      -p   Print mode.  This option causes make to print out the 
  534.           contents of all internal data structures before it begins 
  535.           executing commands.  Useful for debugging.
  536.  
  537.      -q   Query mode.  Causes make to check whether everything is up 
  538.           to date, and exit with a zero return code if so.  If any 
  539.           file is not up to date, a non-zero return code is set, but 
  540.           make does not run any commands to update files.
  541.  
  542.      -r   Don't use builtin rules.  This option disables the internal 
  543.           .SUFFIXES and builtin rules.
  544.  
  545.      -s   Silent mode.  By default, make lists each command as it is 
  546.           executed (unless the first character on the command line is 
  547.           '@').  This option causes make to execute all commands 
  548.           without listing them.
  549.  
  550.      -t   Touch mode.  Instead of running commands to bring files up 
  551.           to date, touch mode will update the file timestamps 
  552.           directly.  Use with caution.
  553.  
  554.   When macros are specified on the command line, they are entered 
  555.   just as they would be in the makefile.  They must follow any 
  556.   options, if options are specified.  For example:
  557.  
  558.      make -s -f altmake CFLAGS=-O 
  559.  
  560.   Would run make using the 'silent' option, using an input file of 
  561.   'altmake' instead of 'makefile', and the CFLAGS macro would be set 
  562.   to a value of '-O'.
  563.  
  564.   When targets are specified on the command line, make will attempt 
  565.   to locate the targets and make them, instead of defaulting to the 
  566.   primary target (the first target found in the makefile).  This can 
  567.   serve several purposes.  If the make implementation supports the 
  568.   end-program filetype via the SUFFIXES mechanism (eg, when make 
  569.   knows how to turn a .c file into a .prg file), then no makefile is 
  570.   needed.  Using a command such as:
  571.  
  572.      make CFLAGS=-O myprog.prg
  573.  
  574.   Make will automatically locate myprog.c, compile it using the '-O' 
  575.   compiler flag, and will run the linker to create myprog.prg.
  576.  
  577.   In addition to the command line targets used in conjunction with 
  578.   the builtin rules, they can be used to make a target from the 
  579.   makefile which is not the primary target.  This can be thought of 
  580.   as an 'alternate entry point' to the makefile.  Given the example:
  581.  
  582.      OBJS  = main.o subr1.o subr2.o
  583.      FILES = main.c subr1.c subr2.c myprog.h
  584.  
  585.      myprog.prg: $(OBJS)
  586.      <tab>linker.prg -o $@ $(OBJS)
  587.  
  588.      $(OBJS): myprog.h
  589.  
  590.      cleanup:
  591.      <tab>delete $(OBJS)
  592.  
  593.      backup:
  594.      <tab>archive add bkpfile.arc $(FILES)
  595.  
  596.   When make is executed without any targets specified on the command 
  597.   line, myprog.prg would be made as normal.  Because the targets 
  598.   'cleanup' and 'backup' don't have any dependents (explicitly or 
  599.   dynamically), they would not trigger any commands to execute.  
  600.   However, if make were run with the target name 'cleanup' on the 
  601.   command line, all the object files would be deleted.  If make were 
  602.   run with the target name 'backup' on the command line, the files 
  603.   which make up the source code for the project would automatically 
  604.   be archived.  Make could be run with both the cleanup and archive 
  605.   targets named, and both associated actions would be taken.
  606.  
  607. MYSTERY FEATURE
  608.  
  609.   Make supports a feature which I have been unable to dig out any 
  610.   documentation for, so I'll present it here for what it's worth:
  611.  
  612.   A target name can be followed by a double colon, as follows:
  613.  
  614.      mylib.a:: dependent
  615.      <tab># command
  616.  
  617.   It seems (from looking at incredibly convoluted source code) that 
  618.   this provides some sort of feature in which a target can appear 
  619.   lots of times in a makefile, having different commands associated 
  620.   with each target/dependent combination.  Don't take my word for it, 
  621.   though.
  622.  
  623. IMPLEMENTATION-SPECIFIC FEATURES
  624.  
  625.   Each of the PD make implementations I've seen has included a small 
  626.   doc file which lists the features and extensions supported (or not 
  627.   supported).  If your version of make didn't include any docs, 
  628.   you'll just have to experiment to find out what features work.
  629.  
  630. HOW THIS DOCUMENT CAME TO BE
  631.  
  632.   Invariably, the little doc files that come with a PD make contain a 
  633.   statement such as "This is not the appropriate forum for a full 
  634.   discussion on how MAKE functions."  The doc file then refers you to 
  635.   'Unix Documentation', although it's never more specific than that.
  636.  
  637.   After spending several frustrating weeks combing book stores (and 
  638.   finding that most Unix books don't even *mention* make), I finally 
  639.   got my hands on a proper Unix System Tools manual.  Using clues 
  640.   garnered from this (rather cryptic) description of make, I went 
  641.   back to the (rather cryptic) PD source code and puzzled out in 
  642.   depth how make functions.
  643.  
  644.   Then I wrote this document so that PD implementations of make can 
  645.   now include more than a version-specific README file.  If you are 
  646.   porting or writing a PD or shareware (or whatever) version of make, 
  647.   please feel free to include this document file with your version.
  648.  
  649. Ian Lepore  (BIX userid ianl)
  650. 06/06/90
  651.  
  652.